package com.sunwayworld.basemodule.common.eptstorage.db.config;

import com.sunwayworld.basemodule.common.eptstorage.db.DbHelper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.context.event.ApplicationReadyEvent;
import org.springframework.context.ApplicationListener;
import org.springframework.core.env.Environment;
import org.springframework.stereotype.Service;

@Service
public class DbConfig implements ApplicationListener<ApplicationReadyEvent> {

    @Autowired
    private Environment environment;
    @Autowired
    private DbHelper dbHelper;

    @Override
    public void onApplicationEvent(ApplicationReadyEvent applicationReadyEvent) {
        String enable = environment.getProperty("lims.dbHelper.enable");
        if("true".equals(enable)){
            dbHelper.register();
        }
    }
}
